<?php

include("classes/include.php");

session_start();

if(isset($_GET['action']))
{
	if($_GET['action'] == "deco")
	{
		session_destroy();
	}
}

if(isset($_POST['id_id']) && isset($_POST['id_ps']))
{

	$login = $_POST['id_id'];
	$mdp = $_POST['id_ps'];

	//$utilisateur = new Etudiant();

	$mess = Utilisateur::identifierInternaute($login,$mdp);
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>ActuStage</title>
	<link href="css/style.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="javascript/blue/style.css" type="text/css" media="print, projection, screen" />
           <link href="css/calendar.css" type="text/css" rel="stylesheet" />
    <script src="scripts/calendar.js"></script>


<script type="text/javascript" src="javascript/jquery-1.6.1.js"></script>
	<script type="text/javascript" src="javascript/jquery.tablesorter.js"></script>
	<script type="text/javascript" src="javascript/jquery.tablesorter.pager.js"></script>
<script language="javascript" type="text/javascript" src="../javascript/datetimepicker.js"></script>

 <script type="text/javascript">

	
	$(document).ready(function() {  
	    // On cr�er notre tablesorter sur l'id mytable  
	    // Et on trie (au d�part) par la premi�re colonne  
	  

		  
			  $("#mytable").tablesorter({widthFixed: true, widgets: ['zebra']})  
	    .tablesorterPager({container: $("#pager"), positionFixed: false});
			});
		
	    // On ajoute la pagination sur l'id #pager  
	
	
	function details(ligne){
var parent = document.getElementById("detail"+ligne).parentNode;
for( var i = 0; i < parent.childNodes.length; i++ ){
 if( parent.childNodes[i].nodeType == 1 && parent.childNodes[i].tagName.toLowerCase() == "div" && parent.childNodes[i].id !="pager"){
	 parent.childNodes[i].style.display="none";
	
}
}

document.getElementById("detail"+ligne).style.display="block";

 }
     

	
	
	</script>
</head>

<body>


	<div id="container">
		<div id="bandeau">
			<a href="index.php"><img src="images/banniere.jpg" width="906" height="110" alt="" /></a> 
         
            <div id="adh">
               <?php 
             	if(!isset($_SESSION['utilisateur']))
            	{
					?>
				<form action="contacts.php" method="post">
                <span style="font-variant: small-caps;color:#FFF;margin-right:5px;font-size:9pt;"> Espace utilisateur</span>
					<input id="identifiant" name="id_id" class="input" value="Nom d'utilisateur" onClick="effacerid();" onblur="remplirid();" style="height:10px;font-size:8pt;" />
					<input id="mot_de_passe" name="id_ps" type="password" value="Mot de passe" onClick="effacermdp();" onblur="remplirmdp();" class="input" style="height:10px;font-size:8pt;" />
					<input type="submit" value="ok" style="font-size:8pt;" alt="" />
				</form>
				<script type="text/javascript">
					function effacerid(){
						document.getElementById( 'identifiant' ).value = "" ;
					}
					function effacermdp(){
						document.getElementById( 'mot_de_passe' ).value = "" ;
					}
					function remplirid(){
						if (!document.getElementById( 'identifiant' ).value){
							document.getElementById( 'identifiant' ).value = "Nom d'utilisateur";}
					}
					function remplirmdp(){
						if (!document.getElementById( 'mot_de_passe' ).value ){
							document.getElementById( 'mot_de_passe' ).value = "Mot de passe" ;}
					}
	
				
				</script>
                    <?php
				}
				else
				if(isset($_SESSION['utilisateur']))
            	{
					$nom = $_SESSION['utilisateur']->getNomUtilisateur();
					$prenom = $_SESSION['utilisateur']->getPrenomUtilisateur();
					?>
					<span style="font-variant: normal-caps;color:#FFF;margin-right:232px;font-size:10pt;"><?php echo 'Bienvenue ', $prenom,' ', $nom; ?></span>
                    <?php                   
				}
			?>
			</div>
        
		</div>
    	<div class="clear"></div>
      <?php   
    include("menu.php");
    ?>
		<div id="contenu">
			<div id="texteaccueil">
         		<div id="titreAcceuil">
       				 <h2>Gestion des agendas <br /> <img src="images/traitBleu.png"width="700" height="3" alt="" /></h2>
       			</div>
        <div id="texte">
        <h3>Rentrer un évenement</h3>
        <form method="post" action="administrationAgenda.php" >
<?php 
$recupPromo = new RequeteSQL("SELECT distinct etu_promotion FROM etudiant ");
		
		$recupPromo->executeQuery();
		echo   " <select name='promoglobal'  > ";
		while($promo = $recupPromo->fetch())
		{
		
   echo "<option value=".$promo['etu_promotion'].">".$promo['etu_promotion']."";

 
		}

 echo "</select> ";
?>
<?php 
$recupSection = new RequeteSQL("SELECT distinct etu_section FROM etudiant ");
		
		$recupSection->executeQuery();
		echo   " <select name='sectionglobal' > ";
		while($section = $recupSection->fetch())
		{
		$section2 = strtr($section['etu_section'], " ", ";");
   echo "<option value=".$section2.">".$section['etu_section']."";

		}

 echo "</select> ";
?>
</br>
</br>
Date de l'évenement <input type="text" name="dateglobal" size="20" id="dateE" maxlength="20" onClick="displayCalendar('dateE', event);" > 
                 <div id="calendar"></div>
</br>
</br>
Intitulé de l'évenement <input type="text" name="intituleglobal" size="20" maxlength="20" > 
</br>
</br>
<input type="submit" name="valideglobal" value="valider"/>
</form>
</br>
 <h3>Rentrer les dates des soutenances</h3>
<form method="post" action="administrationAgenda.php" name="soutenance">
<table border="1" id="mytable" class="tablesorter" cellspacing="1">
	<thead>
		<tr>
			<th>Numéro de l'&eacute;tudiant</th>
			<th>Nom de l'étudiant</th>
            <th>Pr&eacute;nom de l'étudiant</th>
			<th>promotion</th>
		<th>Date soutenance</th>
		
		</tr>
	</thead>
	<tbody>
	<?php

		$listeetudiant = new ListeEtudiant();
		$listeetudiant->remplirListe();
		$listeetudiant->afficherListeEtuAdmin();
		

    ?>
		<tbody>

</table>

<input type="submit" name="valideSout" value="valider"/>
</br>
</br>
<div id="pager" class="pager">
<form><img src="javascript/first.png" class="first"> <img
	src="javascript/prev.png" class="prev"> <input class="pagedisplay"
	type="text"> <img src="javascript/next.png" class="next"> <img
	src="javascript/last.png" class="last"> <select class="pagesize">
	<option selected="selected" value="10">10</option>
	<option value="20">20</option>
	<option value="30">30</option>
	<option value="40">40</option>
</select></form>

</div>

</form>
<?php 

if(isset($_POST['valideglobal'])){
$dateevent=$_POST['dateglobal'];
$eventintitule=$_POST['intituleglobal'];
$promo1= $_POST['promoglobal'];
$section1= $_POST['sectionglobal'];

$section2 = strtr($section1, ";", " ");



$requete = new RequeteSQL("select etu_num_etudiant from etudiant where etu_section=\"".$section2."\" and etu_promotion=\"".$_POST['promoglobal']."\"");
$requete->executeQuery();
   
while ($donnees = $requete->fetch()){
    $etudiant = $donnees['etu_num_etudiant'];
    $requete2 = new RequeteSQL("INSERT INTO agenda (age_num_agenda,age_num_etudiant,age_date,age_intitule) VALUES ('','.$etudiant.',str_to_date('$dateevent','%d/%m/%Y'),'$eventintitule')");
    $requete2->executeQuery();
   
}



}

if(isset($_POST['valideSout'])){


		$recup = new RequeteSQL("SELECT etu_num_etudiant FROM utilisateur,etudiant WHERE uti_num_user = etu_id");
		$recup->executeQuery();
		
		while($ligneEtu = $recup->fetch())
		{
		$etudiant= $ligneEtu['etu_num_etudiant'];
		if(isset($_POST[$etudiant])){
			if($_POST[$etudiant]!=""){

		$updateagenda= new RequeteSQL("UPDATE agenda SET age_date = str_to_date('".$_POST[$etudiant]."','%d/%m/%Y') where age_num_etudiant =".$etudiant." and age_intitule='Soutenance'");
		if(!$updateagenda->executeQuery()){
		
		$recup2 = new RequeteSQL("INSERT INTO agenda (age_num_agenda,age_num_etudiant,age_date,age_intitule) VALUES ('','.$etudiant.',str_to_date('".$_POST[$etudiant]."','%d/%m/%Y %H:%i'),'Soutenance')");
		$recup2->executeQuery();}
		}
		}
		}



}






?>
        </div>    
 		    <div class="clear">
            </div>
          <div id="bas">
    				Universit&eacute; d'Evry-Val-d'Essonne Boulevard Fran&ccedil;ois Mitterrand 91025 Evry Cedex <br /> <a href="contacts.php">Contacts</a>|<a href="planSite.php">Plan du site</a>|<a href="informationsLegales.php">Informations l&eacute;gales</a> 
  				</div>
			</div>
		</div>
		<div class="clear"></div>
    	<div class="clear"></div>
	</div>
</body>
</html>
         	<script type="text/javascript">
			function menu(){
				
				document.getElementById('sub').style.display = 'block';
			
			}
			function sortie(){
				
				document.getElementById('sub').style.display = 'none';
			
			}
				
				</script>
